Skip to content

Conversation

@xzzy
Copy link
Collaborator

@xzzy xzzy commented Nov 28, 2025

No description provided.

@xzzy xzzy merged commit 3308def into dbca-wa:django_5_upgrade Nov 28, 2025
3 of 4 checks passed
Comment on lines +118 to +119
#def from_db_value(self, value, expression, connection, context): # removed due to context error
def from_db_value(self, value, expression, connection):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: UppercaseCharField.from_db_value() signature is incompatible with Django 5.2.5, expecting a context argument that is no longer passed, causing a TypeError.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

When a model instance containing an UppercaseCharField (e.g., postcode in address models) is retrieved from the database, Django 5.2.5 invokes UppercaseCharField.from_db_value() with three arguments (value, expression, connection). However, the UppercaseCharField.from_db_value() method signature at line 84 still expects four arguments, including context. This mismatch causes a TypeError: from_db_value() missing 1 required positional argument: 'context', leading to a server crash during database queries for address-related models.

💡 Suggested Fix

Update the UppercaseCharField.from_db_value() method signature at line 84 to remove the context parameter, matching the fix applied to NullCharField. The signature should be def from_db_value(self, value, expression, connection):.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: oscar/models/fields/__init__.py#L118-L119

Potential issue: When a model instance containing an `UppercaseCharField` (e.g.,
`postcode` in address models) is retrieved from the database, Django 5.2.5 invokes
`UppercaseCharField.from_db_value()` with three arguments (`value`, `expression`,
`connection`). However, the `UppercaseCharField.from_db_value()` method signature at
line 84 still expects four arguments, including `context`. This mismatch causes a
`TypeError: from_db_value() missing 1 required positional argument: 'context'`, leading
to a server crash during database queries for address-related models.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 4199600

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants